package cn.topevery.garden.entity.vo;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.fastjson.annotation.JSONField;
import hw.topevery.framework.Utility;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 人员打卡记录表视图
 *
 * @author code-generate
 * @date 2022-01-12
 */
@Data
@ApiModel(value = "人员打卡记录表 ClockInPeople 视图", description = " 人员打卡记录表视图")
public class ClockInPeopleVO implements Serializable {
    /**
     * 自增id
     */
    private Integer id;

    /**
     * 人员名称
     */
    @ApiModelProperty(value = "人员名称")
    @Excel(name = "人员名称", orderNum = "0")
    private String userName;

    /**
     * 人员id int
     */
    @ApiModelProperty(value = "人员id int")
    @Excel(name = "人员id int", orderNum = "0")
    private Integer userIdInt;

    /**
     * 人员id
     */
    @ApiModelProperty(value = "人员id")
    @Excel(name = "人员id", orderNum = "0")
    private String userId;

    /**
     * 上班日期
     */
    @ApiModelProperty(value = "上班日期")
    @Excel(name = "上班日期", orderNum = "0")
    private LocalDate date;

    /**
     * 上班时间
     */
    @ApiModelProperty(value = "上班时间")
    @Excel(name = "上班时间", orderNum = "0")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime workDate;

    /**
     * 片区
     */
    @ApiModelProperty(value = "片区")
    @Excel(name = "片区", orderNum = "0")
    private String extentName;

    /**
     * 班次
     */
    @ApiModelProperty(value = "班次")
    @Excel(name = "班次", orderNum = "0")
    private String dutyName;

    /**
     * 打卡gps时间
     */
    @ApiModelProperty(value = "打卡gps时间")
    @Excel(name = "打卡gps时间", orderNum = "0")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime gpsDate;

    /**
     * 0 未打卡 1 自动打卡 2 补卡
     */
    @ApiModelProperty(value = "0 未打卡 1 自动打卡 2 补卡")
    @Excel(name = "0 未打卡 1 自动打卡 2 补卡", orderNum = "0")
    private Short type;

    /**
     * 0 异常 1 正常
     */
    @ApiModelProperty(value = "0 异常 1 正常")
    @Excel(name = "0 异常 1 正常", orderNum = "0")
    private Short status;

    /**
     * 坐标
     */
    @ApiModelProperty(value = "坐标 ")
    @Excel(name = "坐标 ", orderNum = "0")
    private Double geoX;

    /**
     * 坐标
     */
    @ApiModelProperty(value = "坐标 ")
    @Excel(name = "坐标 ", orderNum = "0")
    private Double absY;


    /**
     * 坐标
     */
    @ApiModelProperty(value = "坐标 ")
    @Excel(name = "坐标 ", orderNum = "0")
    private Double absX;

    /**
     * 坐标
     */
    @ApiModelProperty(value = "坐标 ")
    @Excel(name = "坐标 ", orderNum = "0")
    private Double geoY;

    /**
     * 位置结果
     */
    @ApiModelProperty(value = "公园地址")
    @Excel(name = "公园地址", orderNum = "0")
    private String address;


    @ApiModelProperty(value = "有效时长")
    @Excel(name = "有效时长", orderNum = "0")
    private Integer validTime;

    @ApiModelProperty(value = "里程")
    @Excel(name = "里程", orderNum = "0")
    private Integer mileage;

    @ApiModelProperty(value = "")
    private String validTimeString;

    public String getValidTimeString() {
        return Utility.GetTimeString(validTime);
    }

    @ApiModelProperty(value = "")
    private String mileageString;

    public String getMileageString() {
        if (mileage > 0) {
            DecimalFormat df = new DecimalFormat("######0.00");
            Double s = mileage / 1000.00;
            return (df.format(s)+"公里");
        }
        return "";
    }


    @ApiModelProperty(value = "")
    private String addressString;

    public String getAddressString() {
        return address == null || address == "" ? "未打卡" : address;
    }

    @ApiModelProperty(value = "")
    private String statusString;

    public String getStatusString() {
        return status == 0 ? "异常" : status == 1 ? "正常" : "";
    }


}